package com.cashmama.market.api.domain.service;

import com.alibaba.fastjson.JSONObject;
import com.cashmama.market.api.domain.vo.user.IFSCCheckResponse;
import com.cashmama.market.api.infras.utils.IFSCHttpUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * IFSC校验
 *
 * @author liuming
 * Created on 下午3:24 2018/9/3.
 */
@Service
public class IFSCServiceProvider {

    /**
     * 校验ifsc
     *
     * @param ifsc
     * @return
     */
    public IFSCCheckResponse ifscCheck(String ifsc) {
        String responseJson = IFSCHttpUtil.sendGet(ifsc);
        if (StringUtils.isBlank(responseJson)) {
            return new IFSCCheckResponse().setCheckSuccess(false);
        }
        IFSCCheckResponse ifscCheckResponse = JSONObject.parseObject(responseJson, IFSCCheckResponse.class);
        ifscCheckResponse.setCheckSuccess(true);
        return ifscCheckResponse;
    }

    public static void main(String[] args) {
        String responseJson = IFSCHttpUtil.sendGet("SBIN0013499");
        System.out.println(responseJson);
    }
}
